package com.esri.core.tasks.geocode;

import com.esri.core.internal.util.d;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class LocatorSuggestionResult {
    private static final String COLLECTION_KEY = "isCollection";
    private static final String JSON_ERROR = "Invalid Json.";
    private static final String MAGIC_KEY_KEY = "magicKey";
    private static final String SUGGESTIONS_KEY = "suggestions";
    private static final String TEXT_KEY = "text";
    private boolean mIsCollection = false;
    private String mMagicKey;
    private String mText;

    LocatorSuggestionResult() {
    }

    public String getText() {
        return this.mText;
    }

    public boolean isCollection() {
        return this.mIsCollection;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public String getMagicKey() {
        return this.mMagicKey;
    }

    public static List<LocatorSuggestionResult> fromJson(JsonParser jsonParser) {
        ArrayList arrayList = new ArrayList();
        if (!d.c(jsonParser)) {
            throw new IllegalArgumentException(JSON_ERROR);
        }
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if (SUGGESTIONS_KEY.equals(currentName)) {
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    LocatorSuggestionResult locatorSuggestionResult = new LocatorSuggestionResult();
                    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                        String currentName2 = jsonParser.getCurrentName();
                        jsonParser.nextToken();
                        if (TEXT_KEY.equals(currentName2)) {
                            locatorSuggestionResult.mText = jsonParser.getText();
                        } else if (MAGIC_KEY_KEY.equals(currentName2)) {
                            locatorSuggestionResult.mMagicKey = jsonParser.getText();
                        } else if (COLLECTION_KEY.equals(currentName2)) {
                            Boolean valueOf = Boolean.valueOf(jsonParser.getBooleanValue());
                            locatorSuggestionResult.mIsCollection = valueOf == null ? false : valueOf.booleanValue();
                        } else {
                            jsonParser.skipChildren();
                        }
                    }
                    arrayList.add(locatorSuggestionResult);
                }
            } else {
                jsonParser.skipChildren();
            }
        }
        return arrayList;
    }

    public String toString() {
        return this.mText;
    }
}
